package com.cai310.lottery.web.controller.lottery.jczq;

import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;

import com.cai310.lottery.Constant;
import com.cai310.lottery.JczqConstant;
import com.cai310.lottery.cache.JczqLocalCache;
import com.cai310.lottery.common.Lottery;
import com.cai310.lottery.common.SalesMode;
import com.cai310.lottery.common.SecretType;
import com.cai310.lottery.dto.lottery.SchemeQueryDTO;
import com.cai310.lottery.dto.lottery.jczq.JczqSchemeDTO;
import com.cai310.lottery.entity.lottery.Period;
import com.cai310.lottery.entity.lottery.jczq.JczqMatch;
import com.cai310.lottery.entity.lottery.jczq.JczqScheme;
import com.cai310.lottery.entity.lottery.jczq.JczqSingleScheme;
import com.cai310.lottery.entity.user.User;
import com.cai310.lottery.exception.DataException;
import com.cai310.lottery.service.ServiceException;
import com.cai310.lottery.service.lottery.PeriodEntityManager;
import com.cai310.lottery.service.lottery.SchemeService;
import com.cai310.lottery.service.lottery.jczq.JczqMatchEntityManager;
import com.cai310.lottery.service.lottery.jczq.JczqSchemeEntityManager;
import com.cai310.lottery.service.lottery.jczq.JczqSchemeService;
import com.cai310.lottery.service.lottery.jczq.JczqSingleSchemeEntityManager;
import com.cai310.lottery.support.Item;
import com.cai310.lottery.support.JcWonMatchItem;
import com.cai310.lottery.support.RateItem;
import com.cai310.lottery.support.jczq.ItemBF;
import com.cai310.lottery.support.jczq.ItemBQQ;
import com.cai310.lottery.support.jczq.ItemJQS;
import com.cai310.lottery.support.jczq.ItemSPF;
import com.cai310.lottery.support.jczq.JczqCompoundContent;
import com.cai310.lottery.support.jczq.JczqContentBean;
import com.cai310.lottery.support.jczq.JczqExtraItem;
import com.cai310.lottery.support.jczq.JczqExtraMatchItem;
import com.cai310.lottery.support.jczq.JczqMatchItem;
import com.cai310.lottery.support.jczq.JczqSimplePrizeWork;
import com.cai310.lottery.support.jczq.JczqTicketCombination;
import com.cai310.lottery.support.jczq.JczqUtil;
import com.cai310.lottery.support.jczq.PassMode;
import com.cai310.lottery.support.jczq.PassType;
import com.cai310.lottery.support.jczq.PlayType;
import com.cai310.lottery.support.jczq.PrizeForecast;
import com.cai310.lottery.support.jczq.TicketItem;
import com.cai310.lottery.support.jczq.TicketSplitCallback;
import com.cai310.lottery.web.controller.GlobalResults;
import com.cai310.lottery.web.controller.WebDataException;
import com.cai310.lottery.web.controller.lottery.SchemeBaseController;
import com.cai310.orm.XDetachedCriteria;
import com.cai310.utils.Struts2Utils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.ibm.icu.util.Calendar;

@Namespace("/" + JczqConstant.KEY)
@Action(value = "scheme")
public class JczqSchemeController extends
		SchemeBaseController<JczqScheme, JczqSchemeDTO, JczqSchemeCreateForm, JczqSchemeUploadForm> {
	@Autowired
	protected PeriodEntityManager periodManager;
	
	private static final long serialVersionUID = 5783479221989581469L;
 
	private PlayType playType;

	private PassMode passMode;

	@Autowired
	private JczqSchemeService schemeService;

	@Autowired
	private JczqSchemeEntityManager schemeEntityManager;
	
	@Autowired
	private JczqSingleSchemeEntityManager jczqSingleSchemeEntityManager;

	@Autowired
	private JczqMatchEntityManager matchEntityManager;

	@Autowired
	private JczqLocalCache localCache;

	private String currentDate;

	private static final int DAY_SIZE = 10;
	
	private List<String> spss = new ArrayList<String>();
	
	private JczqSingleScheme jczqSingleScheme;
	
	/** 场次归属的日期 */
	private String matchDate;
	
	/** 场次归属的日期 */
	private String matchKey;
	
 
	public String getMatchDate() {
		return matchDate;
	}

	public void setMatchDate(String matchDate) {
		this.matchDate = matchDate;
	}

	@Override
	protected SchemeService<JczqScheme, JczqSchemeDTO> getSchemeService() {
		return schemeService;
	}

	@Override
	protected JczqSchemeEntityManager getSchemeEntityManager() {
		return schemeEntityManager;
	}
	/**
	 * 进入添加新方案
	 */
	@Override
	public String editNew() {
		try {
			String single_bet = Struts2Utils.getParameter("single_bet");
			if(StringUtils.isNotBlank(single_bet)){//胜平负单式
				 super.editNew();
				 User user = this.getLoginUser();
					if(null==user)throw new WebDataException("您还没登录。请先登录.");
				 XDetachedCriteria criteria = new XDetachedCriteria(JczqSingleScheme.class, "m");
				 criteria.add(Restrictions.eq("m.userId", user.getId()));
				 criteria.add(Restrictions.eq("m.lotteryType",this.getLotteryType()));
				 criteria.addOrder(Order.desc("m.id"));
				 pagination = queryService.findByCriteriaAndPagination(criteria, pagination);
				 return "editNewSINGLE";
			}else if(null!=passMode&&passMode.equals(PassMode.MIX_PASS)) {
				this.playType = PlayType.MIX;
				super.editNew();
				Map<String, Item[]> itemMap = Maps.newLinkedHashMap();
				Map<String, PlayType> playMap = Maps.newLinkedHashMap();
				for (PlayType playType : PlayType.values()) {
					if(playType.equals(PlayType.MIX))continue;
					itemMap.put(playType.name(), playType.getAllItems());
					if (playType == PlayType.BF) {
						Map<String, Item[]> bfItemMap = Maps.newLinkedHashMap();
						bfItemMap.put("胜", ItemBF.WINS);
						bfItemMap.put("平", ItemBF.DRAWS);
						bfItemMap.put("负", ItemBF.LOSES);
						Struts2Utils.setAttribute("bfItemMap", bfItemMap);
						Struts2Utils.setAttribute("itemColspan", ItemBF.WINS.length);
					}else{
						Struts2Utils.setAttribute(playType.name()+"_itemArr",playType.getAllItems());
					}
					Struts2Utils.setAttribute(playType.name()+"_rateMap",localCache.getRateData(playType, PassMode.PASS));
					playMap.put(playType.name(), playType);
				} 
				Struts2Utils.setAttribute("itemMap",itemMap);
				Struts2Utils.setAttribute("playMap",playMap);
				return "editNewMix";
			}
			return super.editNew();
		} catch (WebDataException e) {
			addActionError(e.getMessage());
		} catch (ServiceException e) {
			addActionError(e.getMessage());
		} catch (Exception e) {
			addActionError(e.getMessage());
			logger.error(e.getMessage(), e);
		}
		return GlobalResults.FWD_ERROR;
	}
	/**
	 * 计算单式注数
	 */
	@Override
	public String calcSingleBetUnits() {
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			List<JczqContentBean> list = this.createForm.buildSingleContentBeanList(this.createForm.getSchemeContent());
			List<Period> periodList = periodManager.findCurrentPeriods(getLotteryType());
			if (periodList == null||periodList.isEmpty()||periodList.size()!=1)
				throw new WebDataException("没有当前开售期.");
			User user = this.getLoginUser();
			if(null==user)throw new WebDataException("您还没登录。请先登录.");
			JczqScheme scheme = null;
			for (JczqContentBean jczqContentBean : list) {
				JczqSchemeDTO schemeDTO = this.createForm.buildSchemeDTO(jczqContentBean, user, periodList.get(0).getId());
				scheme = schemeService.destineScheme(schemeDTO);
				
			}
			JczqSingleScheme jczqSingleScheme = new JczqSingleScheme(list);
			jczqSingleScheme.setUserId(user.getId());
			jczqSingleSchemeEntityManager.saveJczqSingleScheme(jczqSingleScheme);
			map.put("success", true);
			map.put("jczqSingleScheme", jczqSingleScheme);
		} catch (DataException e) {
			map.put("success", false);
			map.put("msg", e.getMessage());
		}catch (WebDataException e) {
			map.put("success", false);
			map.put("msg", e.getMessage());
		}catch (ServiceException e) {
			map.put("success", false);
			map.put("msg", e.getMessage());
		}catch (Exception e) {
			this.logger.error("计算注数发生异常！", e);
			map.put("success", false);
			map.put("msg", "计算注数发生异常！");
		}
		Struts2Utils.renderJson(map);
		return null;
	}
	
	public String dofill(){
		return "";
	}
	
	private List<JczqContentBean> jczqContentBeanList;
	public String oprSingleScheme() {
		String fwd = "oprSingleScheme";
		User loginUser = this.getLoginUser();
		if (loginUser == null) {
			addActionError("您还没登录,请先登录.");
			return forward(false, fwd);
		}
		String id = Struts2Utils.getParameter("id");
		if (StringUtils.isBlank(id)) {
			addActionError("ID为空.");
			return forward(false, fwd);
		}
		jczqSingleScheme = jczqSingleSchemeEntityManager.getJczqSingleScheme(Long.valueOf(id));
		if (null==jczqSingleScheme) {
			addActionError("单式方案内容为空.");
			return forward(false, fwd);
		}
		if ("GET".equals(Struts2Utils.getRequest().getMethod())) {// 转向登录页面
			Integer length = jczqSingleScheme.getLength();
			JczqContentBean jczqContentBean;
			jczqContentBeanList = Lists.newArrayList();
			Struts2Utils.setAttribute("id", id);
			String schemeNum;
			for (int i = 0; i < length; i++) {
				jczqContentBean = new JczqContentBean();
				schemeNum = jczqSingleScheme.getStrByIndex(i, 5);
				if(StringUtils.isNotBlank(schemeNum)){
					jczqContentBean.setSchemeNum(schemeNum);
					if(!"未发起".equals(schemeNum.trim())){
						this.scheme = getSchemeEntityManager().getSchemeBy(schemeNum);
						if(null!=this.scheme&&null!=this.scheme.getSchemePrintState()){
							jczqContentBean.setSchemePrintState(this.scheme.getSchemePrintState());
						}
					}
				}
				jczqContentBean.setContent(jczqSingleScheme.getStrByIndex(i, 0));
				jczqContentBean.setMultiple(Integer.valueOf(jczqSingleScheme.getStrByIndex(i, 1)));
				jczqContentBean.setUnits(Integer.valueOf(jczqSingleScheme.getStrByIndex(i, 2)));
				jczqContentBean.setCost(Integer.valueOf(jczqSingleScheme.getStrByIndex(i, 3)));
				jczqContentBean.setIndex(i);
				List<PassType> passTypes = Lists.newArrayList();
				passTypes.add(PassType.valueOfType(jczqSingleScheme.getStrByIndex(i, 4)));
				jczqContentBean.setPassTypes(passTypes);
				jczqContentBeanList.add(jczqContentBean);
			}
			return forward(true, fwd);
		}

		// 登录操作
		try {
			String index = Struts2Utils.getParameter("index");
			if (StringUtils.isBlank(index)) {
				addActionError("序号为空.");
				return forward(false, fwd);
			}
			String schemeContent = jczqSingleScheme.getStrByIndex(Integer.valueOf(index), 0);
			if (StringUtils.isBlank(schemeContent)) {
				addActionError("投注内容为空.");
				return forward(false, fwd);
			}
			String content = Struts2Utils.getParameter("content");
			if (StringUtils.isBlank(content)) {
				addActionError("页面投注内容为空.");
				return forward(false, fwd);
			}
			if (!content.trim().equals(schemeContent.trim())) {
				addActionError("页面投注内容和投注内容不匹配.");
				return forward(false, fwd);
			}
			this.createForm = new JczqSchemeCreateForm();
			List<JczqContentBean> list = this.createForm.buildSingleContentBeanList(content.trim());
			List<Period> periodList = periodManager.findCurrentPeriods(getLotteryType());
			if (periodList == null||periodList.isEmpty()||periodList.size()!=1)
				throw new WebDataException("没有当前开售期.");
			User user = this.getLoginUser();
			if(null==user)throw new WebDataException("您还没登录。请先登录.");
			if(!user.getId().equals(jczqSingleScheme.getUserId()))throw new WebDataException("您没操作本方案的权利.");
			synchronized (Constant.BASEPATH) {
				JczqSchemeDTO schemeDTO = this.createForm.buildSchemeDTO(list.get(0), user, periodList.get(0).getId());
				JczqScheme scheme = schemeService.createSingleScheme(schemeDTO,jczqSingleScheme,Integer.valueOf(index));
			}
			addActionMessage("发起成功.");
			return success();
		} catch (ServiceException e) {
			addActionError(e.getMessage());
		} catch (Exception e) {
			addActionError(e.getMessage());
			logger.error(e.getMessage(), e);
		}
		return forward(false, fwd);
	}
	
	
	// -------------------------------------------------------
	@Override
	public String list() {
//		if (playType == null)
//			playType = PlayType.SPF;
//		if (passMode == null)
//			passMode = PassMode.PASS;
		List<DateTime> dateList = Lists.newArrayList();
		DateTime now = new DateTime();
		dateList.add(now);
		for (int i = 1; i < DAY_SIZE; i++) {
			dateList.add(now.plusDays(-i));
		}
		Struts2Utils.setAttribute("dateList", dateList);
		return super.list();
	}
 
	@Override
	protected XDetachedCriteria buildListDetachedCriteria() {
		XDetachedCriteria c = super.buildListDetachedCriteria();
		if (playType != null) {
			c.add(Restrictions.eq("m.playType", playType));
		}

		Date date = null;
		if (StringUtils.isNotBlank(currentDate)) {
			try {
				date = DateUtils.parseDate(currentDate, new String[] { "yyyy-MM-dd" });
			} catch (ParseException e) {
			}
			if (date == null) {
				currentDate = null;
			}
		}
		Calendar startTime = Calendar.getInstance();
		Calendar endTime = Calendar.getInstance();
		if (date != null) {
			startTime.setTime(date);
			endTime.setTime(date);
		} else {
			startTime.add(Calendar.DATE, -DAY_SIZE + 1);
		}
		startTime.set(Calendar.HOUR, 0);
		startTime.set(Calendar.MINUTE, 0);
		startTime.set(Calendar.SECOND, 0);
		startTime.set(Calendar.MILLISECOND, 0);
		endTime.set(Calendar.HOUR, 0);
		endTime.set(Calendar.MINUTE, 0);
		endTime.set(Calendar.SECOND, 0);
		endTime.set(Calendar.MILLISECOND, 0);
		endTime.add(Calendar.DATE, 1);
		c.add(Restrictions.ge("m.createTime", startTime.getTime()));
		c.add(Restrictions.lt("m.createTime", endTime.getTime()));

		return c;
	}

	@Override
	protected SchemeQueryDTO buildMySchemeQueryDTO() {
		SchemeQueryDTO queryDTO = super.buildMySchemeQueryDTO();
		if (playType != null) {
			queryDTO.setPlayType(playType.name());
		}
		return queryDTO;
	}

	@Override
	protected String doEditNew() throws Exception {
		List<DateTime> dateList = Lists.newArrayList();
		DateTime now = new DateTime();
		dateList.add(now);
		for (int i = 1; i < DAY_SIZE; i++) {
			dateList.add(now.plusDays(-i));
		}
		Struts2Utils.setAttribute("dateList", dateList);
		
		if (playType == null)
			playType = PlayType.SPF;
		if (passMode == null)
			passMode = PassMode.PASS;
		Struts2Utils.setAttribute("itemArr", playType.getAllItems());
		if (playType == PlayType.BF) {
			Map<String, Item[]> itemMap = Maps.newLinkedHashMap();
			itemMap.put("胜", ItemBF.WINS);
			itemMap.put("平", ItemBF.DRAWS);
			itemMap.put("负", ItemBF.LOSES);
			Struts2Utils.setAttribute("itemMap", itemMap);
			Struts2Utils.setAttribute("itemColspan", ItemBF.WINS.length);
		}
		List<JczqMatch> matchs = findMatchsOfCacheable();
		if (matchs != null && !matchs.isEmpty()) {
			List<String> games = Lists.newArrayList();
			int handicapCount = 0;
			int unHandicapCount = 0;
			Map<String, List<JczqMatch>> matchMap = Maps.newTreeMap();
			for (JczqMatch m : matchs) {
				if (StringUtils.isNotBlank(m.getGameName())) {
					if (!games.contains(m.getGameName()))
						games.add(m.getGameName());
				}

				if (m.getHandicap() != null && m.getHandicap() != 0)
					handicapCount++;
				else
					unHandicapCount++;

				DateTime dateTime = JczqUtil.getDateTime(m.getMatchDate());
				String key = dateTime.toString("yyyy-MM-dd E").replaceAll("星期", "周");

				List<JczqMatch> matchList = matchMap.get(key);
				if (matchList == null)
					matchList = Lists.newArrayList();
				matchList.add(m);
				matchMap.put(key, matchList);
			}
			Struts2Utils.setAttribute("games", games);
			Struts2Utils.setAttribute("handicapCount", handicapCount);
			Struts2Utils.setAttribute("unHandicapCount", unHandicapCount);
			Struts2Utils.setAttribute("matchMap", matchMap);

			Struts2Utils.setAttribute("rateData", localCache.getRateData(playType, passMode));
		}
		///增加
		Map<String, Map<String, RateItem>> sfpRate = localCache.getRateData(PlayType.SPF, PassMode.PASS);
		for (String key : sfpRate.keySet()) {
			
		}
		return super.doEditNew();
	}
	
	public String review() throws Exception {
		List<DateTime> dateList = Lists.newArrayList();
		DateTime now = new DateTime();
		now = now.plusDays(-1);
		if(null==this.matchDate)this.matchDate=now.toString("yyyyMMdd");
		dateList.add(now);
		for (int i = 1; i < DAY_SIZE; i++) {
			dateList.add(now.plusDays(-i));
		}
		Struts2Utils.setAttribute("dateList", dateList);
		
		if (playType == null)
			playType = PlayType.SPF;
		if (passMode == null)
			passMode = PassMode.PASS;

		Struts2Utils.setAttribute("itemArr", playType.getAllItems());
		if (playType == PlayType.BF) {
			Map<String, Item[]> itemMap = Maps.newLinkedHashMap();
			itemMap.put("胜", ItemBF.WINS);
			itemMap.put("平", ItemBF.DRAWS);
			itemMap.put("负", ItemBF.LOSES);
			Struts2Utils.setAttribute("itemMap", itemMap);
			Struts2Utils.setAttribute("itemColspan", ItemBF.WINS.length);
		}

		List<JczqMatch> matchs = findMatchsOfCacheable();
		if (matchs != null && !matchs.isEmpty()) {
			List<String> games = Lists.newArrayList();
			int handicapCount = 0;
			int unHandicapCount = 0;
			Map<String, List<JczqMatch>> matchMap = Maps.newTreeMap();
			for (JczqMatch m : matchs) {
				if (!m.isEnded())
					continue;
				if (StringUtils.isNotBlank(m.getGameName())) {
					if (!games.contains(m.getGameName()))
						games.add(m.getGameName());
				}

				if (m.getHandicap() != null && m.getHandicap() != 0)
					handicapCount++;
				else
					unHandicapCount++;

				DateTime dateTime = JczqUtil.getDateTime(m.getMatchDate());
				String key = dateTime.toString("yyyy-MM-dd E").replaceAll("星期", "周");

				List<JczqMatch> matchList = matchMap.get(key);
				if (matchList == null)
					matchList = Lists.newArrayList();
				matchList.add(m);
				matchMap.put(key, matchList);
			}
			Struts2Utils.setAttribute("games", games);
			Struts2Utils.setAttribute("handicapCount", handicapCount);
			Struts2Utils.setAttribute("unHandicapCount", unHandicapCount);
			Struts2Utils.setAttribute("matchMap", matchMap);

			Struts2Utils.setAttribute("rateData", localCache.getRateData(playType, passMode));
		}
		return "review";
	}
	public String matchOdds(){
		HttpServletResponse response = Struts2Utils.getResponse();
    	response.setContentType("text/xml");
    	response.setCharacterEncoding("UTF-8");
    	response.setHeader("pragma", "no-cache");
    	Map<String, Map<String, RateItem>> rate = localCache.getRateData(this.playType, PassMode.PASS);
    	Map<String, RateItem> map;
    	Map<String, Map<String, RateItem>> matchRate = Maps.newHashMap();
    	String[] arr =  this.matchKey.split(",");
		for (String key : rate.keySet()) {
			for (int i = 0; i < arr.length; i++) {
				if(key.trim().equals(arr[i])){
					map = rate.get(key);
					matchRate.put(key, map);
				}
			}
		}
    	
    	try {
    		String jsonString = JSONObject.fromObject(matchRate).toString();
			response.getOutputStream().println("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
			response.getOutputStream().println("<odds>"+jsonString+"</odds>");
			response.getOutputStream().flush();
			response.getOutputStream().close();
			response.flushBuffer();
		} catch (IOException e) {
			logger.error("查询赔率输出出错---"+this.matchKey);
		}finally{
			try {
				response.getOutputStream().close();
			} catch (IOException e) {
				logger.error("查询赔率关闭出错---"+this.matchKey);
			}
		}
		return null;
	}
	protected List<JczqMatch> findMatchsOfCacheable() {
		List<JczqMatch> matchList  = null;
		if(null==matchDate) {
			matchList = localCache.getMatchList();
		}else {
			matchList = matchEntityManager.findMatchs(Integer.valueOf(matchDate));
		}
		if (matchList == null || matchList.isEmpty()) {
			matchList = matchEntityManager.findMatchsOfUnEnd();
		}
		return matchList;
	}

	@Override
	protected JczqSchemeDTO buildSchemeDTO() throws WebDataException {
		checkCreateForm();

		switch (createForm.getMode()) {
		case COMPOUND:
			checkCreateFormOfCOMPOUND();
			break;
		case SINGLE:
			throw new WebDataException("目前不支持单式投注.");
		default:
			throw new WebDataException("投注方式不合法.");
		}

		JczqSchemeDTO dto = super.buildSchemeDTO();
		dto.setPlayType(playType);
		dto.setSchemeType(createForm.getSchemeType());
		dto.setPassTypes(createForm.getPassTypes());

		Collections.sort(createForm.getItems());
		
		final StringBuilder ticketContentBuilder = new StringBuilder();
		TicketSplitCallback callback = new TicketSplitCallback() {

			@Override
			public void handle(List<JczqMatchItem> matchItemList, PassType passType, int multiple) {
				long matchFlag = JczqUtil.chg2flag(matchItemList, createForm.getItems());
				TicketItem ticketItem = new TicketItem(matchFlag, passType, multiple);
				ticketContentBuilder.append(ticketItem.toString()).append(TicketItem.ITEM_AND);
			}
		};
		switch (createForm.getSchemeType()) {
		case SINGLE:
			dto.setPassMode(PassMode.SINGLE);
            if(createForm.getItems().size()>1)	throw new WebDataException("单关赛事只能选择一场比赛.");//y由于出票上只能出一场比赛
			JczqUtil.singleSplit(callback, createForm.getMultiple(), createForm.getItems());
			break;
		case SIMPLE_PASS:
			dto.setPassMode(PassMode.PASS);

			JczqUtil.splitWithMultiple(callback, createForm.getMultiple(), createForm.getPassTypes().get(0),
					createForm.getItems());
			break;
		case MULTIPLE_PASS:
			dto.setPassMode(PassMode.PASS);

			final List<JczqMatchItem> danList = new ArrayList<JczqMatchItem>();
			final List<JczqMatchItem> undanList = new ArrayList<JczqMatchItem>();
			for (JczqMatchItem item : createForm.getItems()) {
				if (item.isDan())
					danList.add(item);
				else
					undanList.add(item);
			}
			if (danList.size() == 0) {
				Integer maxMatchSize = null;
				if(this.playType.equals(PlayType.MIX)){
					for (JczqMatchItem jczqMatchItem : createForm.getItems()) {
						if(null==maxMatchSize||maxMatchSize>jczqMatchItem.getPlayType().getMaxMatchSize())
							maxMatchSize = jczqMatchItem.getPlayType().getMaxMatchSize();
					}
				}else{
					maxMatchSize = playType.getMaxMatchSize();
				}
				JczqUtil.undanMultiplePassSplit(callback, createForm.getMultiple(), maxMatchSize,
						createForm.getPassTypes(), createForm.getItems());
			} else {
				Integer danMinHit = createForm.getDanMinHit();
				Integer danMaxHit = createForm.getDanMaxHit();
				if (danMinHit == null || danMinHit <= 0)
					danMinHit = danList.size();
				if (danMaxHit == null || danMaxHit <= 0)
					danMaxHit = danList.size();
				JczqUtil.danMultiplePassSplit(callback, createForm.getMultiple(), createForm.getPassTypes(), danList,
						undanList, danMinHit, danMaxHit);
			}
			break;
		}
	    if(null!=createForm.getPassMode()&&PassMode.MIX_PASS.equals(createForm.getPassMode())){
	    	dto.setPassMode(PassMode.MIX_PASS);
	/////////cyy，检查场次是否截至
					List<String> matchKeyList = new ArrayList<String>();
					Map<String,JczqMatchItem> matchItemMap = Maps.newHashMap();
					for (JczqMatchItem item : createForm.getItems()) {
						matchKeyList.add(item.getMatchKey());
						matchItemMap.put(item.getMatchKey(), item);
					}
					List<JczqMatch> matchList = matchEntityManager.findMatchs(matchKeyList);
					for (JczqMatch jczqMatch : matchList) {
						JczqMatchItem item = matchItemMap.get(jczqMatch.getMatchKey());
						if (!jczqMatch.isOpen(item.getPlayType(), PassMode.PASS))
							throw new WebDataException("场次{"+jczqMatch.getMatchKey()+"}已经停止销售.");
						try {
							if (jczqMatch.isStop())
								throw new WebDataException("场次{"+jczqMatch.getMatchKey()+"}已经停止销售.");
						} catch (DataException e) {
							throw new WebDataException("场次{"+jczqMatch.getMatchKey()+"}已经停止销售.");
						}
					}
	    }else{
	    	/////////cyy，检查场次是否截至
			List<String> matchKeyList = new ArrayList<String>();
			for (JczqMatchItem item : createForm.getItems()) {
				matchKeyList.add(item.getMatchKey());
			}
			List<JczqMatch> matchList = matchEntityManager.findMatchs(matchKeyList);
			for (JczqMatch jczqMatch : matchList) {
				if (!jczqMatch.isOpen(dto.getPlayType(), dto.getPassMode()))
					throw new WebDataException("场次{"+jczqMatch.getMatchKey()+"}已经停止销售.");
				try {
					if (jczqMatch.isStop())
						throw new WebDataException("场次{"+jczqMatch.getMatchKey()+"}已经停止销售.");
				} catch (DataException e) {
					throw new WebDataException("场次{"+jczqMatch.getMatchKey()+"}已经停止销售.");
				}
			}
	    }
		if (ticketContentBuilder.length() > 0){
			ticketContentBuilder.delete(ticketContentBuilder.length() - TicketItem.ITEM_AND.length(),
					ticketContentBuilder.length());
		}else{
			throw new WebDataException("投注拆票出现错误。请联系客服.");
		}
		dto.setTicketContent(ticketContentBuilder.toString());
		return dto;
	}

	protected void checkCreateForm() throws WebDataException {
		if (createForm == null)
			throw new WebDataException("表单数据为空.");

		if (playType == null)
			throw new WebDataException("玩法类型不能为空.");

		if (createForm.getSchemeType() == null)
			throw new WebDataException("方案类型不能为空.");
		if (createForm.getPassTypes() == null || createForm.getPassTypes().isEmpty())
			throw new WebDataException("过关方式不能为空.");
	}

	protected void checkCreateFormOfCOMPOUND() throws WebDataException {
		if (createForm.getItems() == null || createForm.getItems().isEmpty())
			throw new WebDataException("投注内容不能为空.");

		Integer maxMatchSize = null;
		switch (createForm.getSchemeType()) {
		case SINGLE:
			if (createForm.getItems().size() > JczqConstant.SINGLE_MAX_MATCH_SIZE)
				throw new WebDataException("单关模式不能选择超过" + JczqConstant.SINGLE_MAX_MATCH_SIZE + "场.");

			if (createForm.getPassTypes() == null || createForm.getPassTypes().size() != 1
					|| createForm.getPassTypes().get(0) != PassType.P1)
				throw new WebDataException("过关方式不正确.");
			break;
		case SIMPLE_PASS:
			if(this.playType.equals(PlayType.MIX)){
				for (JczqMatchItem jczqMatchItem : createForm.getItems()) {
					if(null==maxMatchSize||maxMatchSize>jczqMatchItem.getPlayType().getMaxMatchSize())
						maxMatchSize = jczqMatchItem.getPlayType().getMaxMatchSize();
				}
			}else{
				maxMatchSize = playType.getMaxMatchSize();
			}
			if (createForm.getItems().size() > maxMatchSize)
				throw new WebDataException("[" + playType.getText() + "]普通过关选择不能超过" + maxMatchSize + "场.");

			if (createForm.getPassTypes().size() > 1)
				throw new WebDataException("普通过关模式只能选择一个过关方式.");

			PassType passType = createForm.getPassTypes().get(0);
			if (passType == PassType.P1)
				throw new WebDataException("过关模式不能选择单关过关方式.");
			if (passType.getMatchCount() != createForm.getItems().size())
				throw new WebDataException("选择的场次数目与过关方式不匹配.");
			break;
		case MULTIPLE_PASS:
			for (PassType type : createForm.getPassTypes()) {
				if (type.getUnits() != 1)
					throw new WebDataException("多选过关模式不支持[" + type.getText() + "]过关.");
				if(this.playType.equals(PlayType.MIX)){
					maxMatchSize = null;
					for (JczqMatchItem jczqMatchItem : createForm.getItems()) {
						if(null==maxMatchSize||maxMatchSize>jczqMatchItem.getPlayType().getMaxMatchSize())
							maxMatchSize = jczqMatchItem.getPlayType().getMaxMatchSize();
					}
					if (type.getMatchCount() > maxMatchSize)
						throw new WebDataException("过关方式不正确.");
				}else{
					if (type.getMatchCount() > playType.getMaxMatchSize())
						throw new WebDataException("过关方式不正确.");
				}
			}
			break;
		default:
			throw new WebDataException("过关模式不合法.");
		}
	}
	@Override
	protected String doShow() throws WebDataException {
		if (scheme != null) {
			if (scheme.getMode() == SalesMode.COMPOUND) {
				StringBuilder sb = new StringBuilder();
				JczqCompoundContent compoundContent = scheme.getCompoundContent();
				Struts2Utils.setAttribute("compoundContent", compoundContent);
                
				Map<String, JczqMatch> matchMap = Maps.newLinkedHashMap();
				List<String> matchKeys = Lists.newArrayList();
				for (JczqMatchItem matchItem : compoundContent.getItems()) {
					matchKeys.add(matchItem.getMatchKey());
				}
				List<JczqMatch> matchs = matchEntityManager.findMatchs(matchKeys);
				Struts2Utils.setAttribute("matchs", matchs);
				for (JczqMatch jczqMatch : matchs) {
					matchMap.put(jczqMatch.getMatchKey(), jczqMatch);
				}
				
				
				int danSize = 0;
				Map<String, String> contentMap = Maps.newLinkedHashMap();
				Map<String, String> playTypeMap = Maps.newLinkedHashMap();
				Map<String, String> resultMap = Maps.newLinkedHashMap();
				for (JczqMatchItem matchItem : compoundContent.getItems()) {
					sb.setLength(0);
					if (matchItem.isDan()) {
						sb.append("(胆)");
						danSize++;
					}
					if(PassMode.MIX_PASS.equals(scheme.getPassMode())){
						JczqMatch jczqMatch = matchMap.get(matchItem.getMatchKey());
                        if(matchItem.getPlayType().equals(PlayType.RQSPF)){
    						playTypeMap.put(matchItem.getMatchKey(), matchItem.getPlayType().getText()+(null==jczqMatch.getHandicap()?"-":"("+jczqMatch.getHandicap()+")"));
                        }else{
                        	playTypeMap.put(matchItem.getMatchKey(), matchItem.getPlayType().getText());
                        }
						for (Item item : matchItem.getPlayType().getAllItems()) {
							if ((matchItem.getValue() & (0x1 << item.ordinal())) > 0) {
								if(null==jczqMatch){
									sb.append(item.getText()).append(",");
								}else{
									if(null!=jczqMatch.getResult(matchItem.getPlayType())&&item.equals(jczqMatch.getResult(matchItem.getPlayType()))){
										sb.append("<font style=\"color:red;\">"+item.getText()+"</font>").append(",");
										//命中
									}else{
										sb.append(item.getText()).append(",");
									}
									
								}
								
							}
						}
						if (sb.length() > 0) {
							sb.deleteCharAt(sb.length() - 1);
						}
						if(null!=jczqMatch.getResult(matchItem.getPlayType())){
							resultMap.put(matchItem.getMatchKey(), jczqMatch.getResult(matchItem.getPlayType()).getText());
						}
						contentMap.put(matchItem.getMatchKey(), sb.toString());
					}else{
						JczqMatch jczqMatch = matchMap.get(matchItem.getMatchKey());
						if(scheme.getPlayType().equals(PlayType.RQSPF)){
    						playTypeMap.put(matchItem.getMatchKey(), scheme.getPlayType().getText()+(null==jczqMatch.getHandicap()?"-":"("+jczqMatch.getHandicap()+")"));
                        }else{
                        	playTypeMap.put(matchItem.getMatchKey(), scheme.getPlayType().getText());
                        }
						playTypeMap.put(matchItem.getMatchKey(), scheme.getPlayType().getText());
						for (Item item : scheme.getPlayType().getAllItems()) {
							if ((matchItem.getValue() & (0x1 << item.ordinal())) > 0) {
								if(null==jczqMatch){
									sb.append(item.getText()).append(",");
								}else{
									if(null!=jczqMatch.getResult(scheme.getPlayType())&&item.equals(jczqMatch.getResult(scheme.getPlayType()))){
										sb.append("<font style=\"color:red;\">"+item.getText()+"</font>").append(",");
										//命中
									}else{
										sb.append(item.getText()).append(",");
									}
									
								}
							}
						}
						if (sb.length() > 0) {
							sb.deleteCharAt(sb.length() - 1);
						}
						contentMap.put(matchItem.getMatchKey(), sb.toString());
					}
				}
				Struts2Utils.setAttribute("contentMap", contentMap);
				Struts2Utils.setAttribute("resultMap", resultMap);
				Struts2Utils.setAttribute("playTypeMap", playTypeMap);
				sb.setLength(0);
				if (compoundContent.getDanMinHit() != null && compoundContent.getDanMinHit() > 0) {
					sb.append("胆码至少命中").append(compoundContent.getDanMinHit()).append("场");
				}
				if (compoundContent.getDanMaxHit() != null && compoundContent.getDanMaxHit() > 0
						&& compoundContent.getDanMaxHit() < danSize) {
					if (sb.length() > 0)
						sb.append(",");
					sb.append("胆码至多命中").append(compoundContent.getDanMaxHit()).append("场");
				}
				if (sb.length() > 0)
					Struts2Utils.setAttribute("mohusheda", sb.toString());

				
				
				
				
				////时间
				if (this.scheme.isCanSubscribe() && this.period.isOnSale()&&null!=this.scheme.getCommitTime()) {
					handleCanSubscribe(this.scheme.getCommitTime());
				}
			}
		}
		if(PassMode.MIX_PASS.equals(scheme.getPassMode())){
			return "showMix";
		}else{
			return super.doShow();
		}
	}

	@Override
	public String canViewDetail(JczqScheme scheme, Period period, User user) {
		if (user != null && user.getId().equals(scheme.getSponsorId()))
			return "true";
		switch (scheme.getSecretType()) {
		case FULL_PUBLIC:
			return "true";
		case DRAWN_PUBLIC:
			if (period.isDrawed() && scheme.isUpdateWon())
				return "true";
			else
				return SecretType.DRAWN_PUBLIC.getSecretName();
		}
		return "方案保密";
	}

	@Override
	public String myList() {
		if (playType == null)
			playType = PlayType.SPF;
		return super.myList();
	}

	public String viewTicketCombination() {
		String returnString = "ticketCombination";
		if(null!=Struts2Utils.getParameter("type")){
			///单式
			returnString="ticketCombination-single";
		}
		try {
			if (this.id != null)
				this.scheme = getSchemeEntityManager().getScheme(this.id);
			else {
				String schemeNumber = Struts2Utils.getRequest().getParameter("schemeNumber");
				if (StringUtils.isBlank(schemeNumber))
					throw new WebDataException("方案号为空.");
				this.scheme = getSchemeEntityManager().getSchemeBy(schemeNumber);
			}
			if (this.scheme == null)
				throw new WebDataException("方案不存在.");
            
			if (this.scheme.getPassMode() == PassMode.SINGLE)
				throw new WebDataException("只有过关投注才有[票面奖金明细]!");

			boolean onlyWon = "true".equals(Struts2Utils.getRequest().getParameter("onlyWon"));// 仅查看中奖的

			// 是否允许查看
			this.period = this.periodEntityManager.getPeriod(scheme.getPeriodId());
			String view = canViewDetail(scheme, period, getLoginUser());
			if (!"true".equalsIgnoreCase(view))
				throw new WebDataException(view);

			// 该 玩法选项
			Map<String, Item> itemMap = Maps.newHashMap();
			if(this.scheme.getPassMode().equals(PassMode.MIX_PASS)){
            	returnString="ticketCombination-mix";
            }else{
    			for (Item optionItem : this.scheme.getPlayType().getAllItems()) {
    				itemMap.put(optionItem.getValue(), optionItem);
    			}
            }
			Struts2Utils.getRequest().setAttribute("itemMap", itemMap);

			// 拆票內容
			List<TicketItem> ticketList = this.scheme.getTicketList();

			JczqCompoundContent compound = this.scheme.getCompoundContent();

			// 总选择的場次内容
			List<JczqMatchItem> matchItemList = compound.getItems();

			// 出票信息
			List<Map<String, Map<String, Double>>> printAwardList = this.scheme.getPrintAwardList();

			Map<String, JczqMatchItem> mathItemMap = Maps.newHashMap();
			for (JczqMatchItem matchItem : matchItemList) {
				mathItemMap.put(matchItem.getMatchKey(), matchItem);
			}
			// 加载对应的对阵
			List<JczqMatch> matchList = matchEntityManager.findMatchs(Lists.newArrayList(mathItemMap.keySet()));
			Map<String, JczqMatch> matchMap = Maps.newHashMap();
			for (JczqMatch match : matchList) {
				String matchKey = match.getMatchKey();
				matchMap.put(matchKey, match);
			}
			Struts2Utils.getRequest().setAttribute("matchMap", matchMap);

			// 分页查询
			pagination.setTotalCount(ticketList.size());
			List<JczqTicketCombination> resultList = new ArrayList<JczqTicketCombination>();
			int count = 0;
			for (int i = 0; i < pagination.getTotalCount(); i++) {
				boolean won = false;
				if (count >= pagination.getFirst()) {
					TicketItem ticketItem = ticketList.get(i);

					// 获取选择场次内容
					List<JczqMatchItem> itemList = new ArrayList<JczqMatchItem>();
					if (ticketItem.getMatchFlag() == 0) {
						itemList = matchItemList;
					} else {
						for (int p = 0; p < matchItemList.size(); p++) {
							if ((ticketItem.getMatchFlag() & (0x1l << p)) > 0)
								itemList.add(matchItemList.get(p));
						}
					}

					// 检查出票、装载出票SP值与更新中奖
					Double totalPrizeAfterTax = null;
					Map<String, Map<String, Double>> matchPrintAwardMap = (printAwardList != null) ? printAwardList
							.get(i) : null;
					boolean printed = matchPrintAwardMap != null && !matchPrintAwardMap.isEmpty();// 检查出票
					if (printed) {
						// 更新中奖
						List<JcWonMatchItem> correctList = new ArrayList<JcWonMatchItem>();
						for (JczqMatchItem matchItem : itemList) {
							String matchKey = matchItem.getMatchKey();
							JczqMatch match = matchMap.get(matchKey);

							Map<String, Double> awardMap = matchPrintAwardMap.get(matchItem.getMatchKey());

							if (match.isCancel()) {
								JcWonMatchItem wonItem = new JcWonMatchItem();
								wonItem.setMatchKey(matchKey);
								wonItem.setSelectCount(matchItem.selectedCount());
								wonItem.setCancel(true);
								wonItem.setAward(1d);
								correctList.add(wonItem);
								continue;
							} else if (match.isEnded()) {
								Item rs = null;
								if(this.scheme.getPassMode().equals(PassMode.MIX_PASS)){
									 rs = match.getResult(matchItem.getPlayType());
								}else{
									 rs = match.getResult(this.scheme.getPlayType());
								}
								if (rs != null) {
									if (matchItem.hasSelect(rs)) {
										JcWonMatchItem wonItem = new JcWonMatchItem();
										wonItem.setMatchKey(matchKey);
										wonItem.setSelectCount(matchItem.selectedCount());
										wonItem.setResultItem(rs);
										Double award = Double.valueOf(""+awardMap.get(rs.getValue()));
										wonItem.setAward(award);
										correctList.add(wonItem);
										continue;
									}
								}
							}
						}
						if (correctList.size() >= ticketItem.getPassType().getPassMatchs()[0]) {
							JczqSimplePrizeWork prizeWork = new JczqSimplePrizeWork(this.scheme.getPassMode(),
									ticketItem.getMultiple(), ticketItem.getPassType(), correctList);
							totalPrizeAfterTax = prizeWork.getTotalPrizeAfterTax();
						}
					}
					won = totalPrizeAfterTax != null && totalPrizeAfterTax > 0;
					if (!onlyWon || won) {
						JczqTicketCombination comb = new JczqTicketCombination(this.scheme.getPassMode(),this.scheme.getPlayType(), itemList,
								ticketItem.getPassType(), ticketItem.getMultiple(), matchPrintAwardMap,
								totalPrizeAfterTax);
						resultList.add(comb);
						if (resultList.size() == pagination.getPageSize())
							break;
					}
				}
				if (!onlyWon || won)
					count++;
			}
			pagination.setResult(resultList);
			return returnString;
		} catch (WebDataException e) {
			addActionError(e.getMessage());
			Struts2Utils.getRequest().setAttribute("error", e.getMessage());
		} catch (DataException e) {
			addActionError(e.getMessage());
			Struts2Utils.getRequest().setAttribute("error", "网络忙！请稍后再试");
		} catch (Exception e) {
			addActionError(e.getMessage());
			logger.error(e.getMessage(), e);
			Struts2Utils.getRequest().setAttribute("error", "网络忙！请稍后再试");
		}

		return "combination-error";
	}
	public String prizeForecastOfInit() {
		try {
			if (playType == null)
				throw new WebDataException("玩法类型为空.");
			if (createForm == null)
				throw new WebDataException("表单为空.");
			if (createForm.getPeriodId() == null)
				throw new WebDataException("期ID为空.");
			if (createForm.getMultiple() == null || createForm.getMultiple() < 1)
				throw new WebDataException("倍数不正确.");
			if (createForm.getItems() == null || createForm.getItems().isEmpty())
				throw new WebDataException("场欠内容为空.");
			if (createForm.getPassTypes() == null || createForm.getPassTypes().isEmpty())
				throw new WebDataException("过关方式为空.");

			for (PassType passType : createForm.getPassTypes()) {
				if (passType.getUnits() > 1 && createForm.getPassTypes().size() > 1)
					throw new WebDataException("过关方式不正确.");
			}

			return prizeForecast(createForm.getPeriodId(), playType, createForm.getItems(), createForm.getMultiple(),
					createForm.getPassTypes(), createForm.getDanMinHit(), createForm.getDanMaxHit());
		} catch (WebDataException e) {
			addActionError(e.getMessage());
		} catch (Exception e) {
			addActionError(e.getMessage());
			logger.error(e.getMessage(), e);
		}
		return GlobalResults.FWD_ERROR;
	}

	public String prizeForecastOfScheme() {
		try {
			if (id != null)
				scheme = getSchemeEntityManager().getScheme(id);
			else {
				String schemeNumber = Struts2Utils.getRequest().getParameter("schemeNumber");
				if (StringUtils.isBlank(schemeNumber))
					throw new WebDataException("方案号为空.");
				scheme = getSchemeEntityManager().getSchemeBy(schemeNumber);
			}
			if (scheme == null)
				throw new WebDataException("方案不存在.");
			if (!scheme.isCompoundMode())
				throw new WebDataException("只有复式方案才支持奖金预测.");

			JczqCompoundContent compoundContent = scheme.getCompoundContent();

			return prizeForecast(scheme.getPeriodId(), scheme.getPlayType(), compoundContent.getItems(),
					scheme.getMultiple(), scheme.getPassTypeList(), compoundContent.getDanMinHit(),
					compoundContent.getDanMaxHit());
		} catch (WebDataException e) {
			addActionError(e.getMessage());
		} catch (Exception e) {
			addActionError(e.getMessage());
			logger.error(e.getMessage(), e);
		}
		return GlobalResults.FWD_ERROR;
	}

	protected String prizeForecast(Long periodId, PlayType playType, List<JczqMatchItem> items, Integer multiple,
			List<PassType> passTypes, Integer danMinHit, Integer danMaxHit) throws WebDataException {
		if (spss == null || spss.isEmpty())
			throw new WebDataException("SP数据为空.");
		else if (spss.size() != items.size())
			throw new WebDataException("SP数据数目与场次数目不对应.");

		List<String> matchKeyList = new ArrayList<String>();
		for (JczqMatchItem matchItem : items) {
			matchKeyList.add(matchItem.getMatchKey());
		}

		List<JczqMatch>  matchlist = matchEntityManager.findMatchs(matchKeyList);
		Map<String,JczqMatch> matchMap = new HashMap<String,JczqMatch>();
		for(JczqMatch jczqMatch:matchlist) {
			matchMap.put(jczqMatch.getMatchKey(), jczqMatch);
		}
		
		if (matchMap == null || matchMap.size() != matchKeyList.size())
			throw new WebDataException("找不到对应场次的赛事.");
		Struts2Utils.setAttribute("matchMap", matchMap);

		Item[] allItems = playType.getAllItems();
		List<JczqExtraMatchItem> extraMatchItemList = new ArrayList<JczqExtraMatchItem>();
		for (int i = 0; i < items.size(); i++) {
			JczqMatchItem matchItem = items.get(i);

			JczqMatch match = matchMap.get(matchItem.getMatchKey());
			Item resultItem = null;
			Double resultSp = null;
			if (match.isEnded()) {
				resultItem = match.getResult(playType);
				resultSp = match.getResultSp(playType);
			}
            if(PlayType.MIX.equals(playType)){
            	allItems = matchItem.getPlayType().getAllItems();
            }
			List<JczqExtraItem> values = new ArrayList<JczqExtraItem>();
			String spsStr = this.spss.get(i);
			if (StringUtils.isBlank(spsStr))
				throw new WebDataException("SP值数据不正确.");
			String[] spArr = spsStr.split(",");
			int k = 0;
			for (Item item : allItems) {
				if (matchItem.hasSelect(item)) {
					Double sp;
					if (match.isCancel()) {
						sp = JczqConstant.CANCEL_MATCH_RESULT_SP;
					} else if (match.isEnded() && resultItem != null && resultSp != null) {
						sp = resultSp;
					} else {
						if (k >= spArr.length)
							throw new WebDataException("SP值数据不正确.");
						String spStr = spArr[k];
						sp = (StringUtils.isNotBlank(spStr)) ? Double.valueOf(spStr) : 0.0d;
					}

					JczqExtraItem extraItem = new JczqExtraItem();
					extraItem.setItem(item);
					extraItem.setSp(sp);
					values.add(extraItem);

					k++;
				}
			}

			JczqExtraMatchItem extraMatchItem = new JczqExtraMatchItem();
			extraMatchItem.setMatchKey(matchItem.getMatchKey());
			extraMatchItem.setDan(matchItem.isDan());
			extraMatchItem.setValues(values);
			extraMatchItem.setCancel(match.isCancel());
			if (match.isEnded() && resultItem != null && resultSp != null) {
				extraMatchItem.setEnd(true);
				extraMatchItem.setResultItem(resultItem);
				extraMatchItem.setResultSp(resultSp);
			}
			extraMatchItemList.add(extraMatchItem);
		}

		Struts2Utils.setAttribute("playType", playType);

		PrizeForecast prizeForecast = new PrizeForecast(multiple, extraMatchItemList, passTypes, danMinHit, danMaxHit);
		Struts2Utils.setAttribute("prizeForecast", prizeForecast);

		return "prize-forecast";
	}
	

	
	
	
	
	public List<String> getSpss() {
		return spss;
	}

	public void setSpss(List<String> spss) {
		this.spss = spss;
	}
	// -------------------------------------------------------

	public JczqSchemeCreateForm getCreateForm() {
		return createForm;
	}

	public void setCreateForm(JczqSchemeCreateForm createForm) {
		this.createForm = createForm;
	}

	@Override
	public Lottery getLotteryType() {
		return Lottery.JCZQ;
	}

	public PlayType getPlayType() {
		return playType;
	}

	public void setPlayType(PlayType playType) {
		this.playType = playType;
	}

	public PassMode getPassMode() {
		return passMode;
	}

	public void setPassMode(PassMode passMode) {
		this.passMode = passMode;
	}

	public String getCurrentDate() {
		return currentDate;
	}

	public void setCurrentDate(String currentDate) {
		this.currentDate = currentDate;
	}

	public JczqSingleScheme getJczqSingleScheme() {
		return jczqSingleScheme;
	}

	public void setJczqSingleScheme(JczqSingleScheme jczqSingleScheme) {
		this.jczqSingleScheme = jczqSingleScheme;
	}

	public List<JczqContentBean> getJczqContentBeanList() {
		return jczqContentBeanList;
	}

	public void setJczqContentBeanList(List<JczqContentBean> jczqContentBeanList) {
		this.jczqContentBeanList = jczqContentBeanList;
	}

	public String getMatchKey() {
		return matchKey;
	}

	public void setMatchKey(String matchKey) {
		this.matchKey = matchKey;
	}

}
